@echo off
echo ========================================
echo 测试设备API接口
echo ========================================

echo.
echo 1. 测试系统状态...
powershell -Command "try { $result = Invoke-RestMethod -Uri 'http://localhost:8081/api/home/system-status' -Method GET; Write-Host '系统状态正常:' $result.message } catch { Write-Host '系统状态检查失败:' $_.Exception.Message }"

echo.
echo.
echo 2. 测试获取用户1的设备...
powershell -Command "try { $result = Invoke-RestMethod -Uri 'http://localhost:8081/api/devices/user/1' -Method GET; Write-Host '设备数量:' $result.Count; $result | ForEach-Object { Write-Host '设备:' $_.name '状态:' $_.status } } catch { Write-Host '获取设备失败:' $_.Exception.Message }"

echo.
echo.
echo 3. 测试获取所有用户...
powershell -Command "try { $result = Invoke-RestMethod -Uri 'http://localhost:8081/api/users' -Method GET; Write-Host '用户数量:' $result.Count; $result | ForEach-Object { Write-Host '用户:' $_.username 'ID:' $_.id } } catch { Write-Host '获取用户失败:' $_.Exception.Message }"

echo.
echo.
echo 4. 测试获取设备类型...
powershell -Command "try { $result = Invoke-RestMethod -Uri 'http://localhost:8081/api/device-types' -Method GET; Write-Host '设备类型数量:' $result.Count; $result | ForEach-Object { Write-Host '类型:' $_.name } } catch { Write-Host '获取设备类型失败:' $_.Exception.Message }"

echo.
echo.
echo ========================================
echo 测试完成！
echo ========================================
pause

